from core.basehandler import BaseHandler
from core.room import Room
from core.support import set_cutscene, get_game
from core.action import Action

class FirstFloor(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        self.treasure_locked = True
        self.lock_rusty = True
        
        # build list of actions
        self.add_action(Up)
        self.add_action(In)
        self.add_action(GetOuttaThere)
        
#        for item in self.inventory:
#            if item
    
    def get_description(self):
        #if self.is_illuminated():
        desc = 'You are on the first floor'
        #else:
            #desc = "You are in what feels like a dank basement.  It is pitch dark."
        return desc
    
    def get_image(self):
        #if self.is_illuminated():
            return 'Lobby.jpg'
        #else:
            #return 'basement.jpg'
    
    # report whether this room is illuminated
    # which can happen if the room or player has a lit lamp
           

class FirstFloorHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return FirstFloor

# define actions for this room

class Up(Action):
    def __init__(self):
        Action.__init__(self, "Up")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go Upstairs"
    
    # set cutscene for when arrive in entrance_hall
    def do_action(self,game,room,request):
        set_cutscene("You climb the stairs.")
        return
        
    # return id of room to enter when action is complete
    def get_destination(self):
        return "secondFloor"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
class In(Action):
    def __init__(self):
        Action.__init__(self, "In")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go inside the Atrium"

    # set cutscene for when arrive in entrance_hall
    def do_action(self,game,room,request):
        set_cutscene("You walk into the room")
        return
        
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'DellarocasRoom'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

class GetOuttaThere(Action):
    def __init__(self):
        Action.__init__(self, "GetOuttaThere")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Get Outta Here!!"

    # set cutscene for when arrive in entrance_hall
    def do_action(self,game,room,request):
        set_cutscene("You get out of SMG!")
        return
        
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'Outside'

    # should this action be available to player?
    # default is yes, but can be overridden.
    def is_enabled(self):
        game = get_game()
        player = game.get_player()
        if 'bu_id' in player.inventory:
            if player.inventory['bu_id'].wholeId:
                return True
        return False

        
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"        